//
//  BaseModel.m
//  FitTime
//
//  Created by 赵建平 on 16/3/30.
//  Copyright © 2016年 赵建平. All rights reserved.
//

#import "BaseModel.h"

@implementation BaseModel

/*****************************初始化***************************/
- (instancetype)initWithDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

/*****************************便利构造器***************************/
+ (instancetype)baseModelWithDic:(NSDictionary *)dic
{
    id objc= [[[self class] alloc] initWithDic:dic];
    return objc;
}

/*****************************容错方法***************************/
- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}
- (id)valueForUndefinedKey:(NSString *)key
{
    return nil;
}

/*****************************转化方法***************************/
+ (NSMutableArray *)arrayWithModelArray:(NSArray *)array
{
    NSMutableArray *arr = [NSMutableArray array];
    for (NSDictionary *dic in array) {
        @autoreleasepool {
            id model = [[self class] baseModelWithDic:dic];
            [arr addObject:model];
        }
    }
    return arr;
}


@end
